package com.xiaomi.shop.service.impl;

import com.xiaomi.shop.entity.Admin;
import com.xiaomi.shop.entity.AdminExample;
import com.xiaomi.shop.mapper.AdminMapper;
import com.xiaomi.shop.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName 陈欣月
 * @Descripttion TODO
 * @Author cxy
 * @Date 2021/10/13 15:11
 * @Version 1.0
 **/
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public String login(String name, String pwd) {
        //返回值
        String flag="no";//失败
        //使用查询方法
        AdminExample example = new AdminExample();
        //将用户名封装到查询中
        example.createCriteria().andANameEqualTo(name);
        //调用自动生成的方法
        List<Admin> list = adminMapper.selectByExample(example);
        if(list!=null && list.size()>0){
            Admin admin = list.get(0);
            //下面比对密码
            if(pwd.equals(admin.getaPass())){
                //您是合法用户
                flag="ok";
            }

        }

        return flag;
    }
}
